 package com.bill.gaty.mfidelity.dto;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map.Entry;

import android.util.Log;

import com.bill.gaty.mfidelity.beans.Gtf;
import com.bill.gaty.mfidelity.type.GtfResponseType;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
 


public class GtfResponse {
private GtfResponseType reponse;
 
private String question;
private int numero;
public GtfResponse(GtfResponseType reponse, String question, int numero) {
	super();
	this.reponse = reponse;
	this.question = question;
	this.numero = numero;
}
public int getNumero() {
	return numero;
}
public void setNumero(int numero) {
	this.numero = numero;
}
public GtfResponseType getReponse() {
	return reponse;
}
public void setReponse(GtfResponseType reponse) {
	this.reponse = reponse;
}
 
public GtfResponse(GtfResponseType reponse, String question) {
	super();
	this.reponse = reponse;
	this.question = question;
}
 
public GtfResponse() {
	super();
	// TODO Auto-generated constructor stub
}
 
 
public String getQuestion() {
	return question;
}
public void setQuestion(String question) {
	this.question = question;
}
 public static  Gtf  toGtf(LinkedHashMap<Integer, GtfResponse> responses){
	 Iterator<Entry<Integer, GtfResponse>> it = responses.entrySet().iterator();
	try{
	 List<GtfResponse> respon=new ArrayList<GtfResponse>();
	 while(it.hasNext())
		 respon.add(it.next().getValue());
	 java.lang.reflect.Type collectionType = new TypeToken< List<GtfResponse>>(){}.getType();
    Gson g=new Gson();
	return new Gtf(g.toJson(respon, collectionType ));
}catch (Exception e) {
	// TODO: handle exception
	Log.e("toGtf_Exception",e.getMessage());
}
  return null; 
}
}
